package com.bci.pwtz.task.thread;

import org.apache.log4j.Logger;

public class BaseThread implements Runnable
{
    private final static Logger _logger = Logger.getLogger(BaseThread.class);
    
    public int interval;
    public String threadName;
    public void doWork() throws Exception
    {
        
    }
    @Override
    public void run()
    {
        while(true)
        {
            try
            {
                if(_logger.isDebugEnabled())
                {
                    _logger.debug(threadName + "任务开始执行,interval="+interval+"s");
                }
                doWork();                
            }
            catch(Exception e)
            {
                _logger.error(threadName + "任务执行异常",e);
            }
            try
            {
                Thread.sleep(interval*1000);
            }
            catch(InterruptedException e)
            {}
        }
        
    }

}
